package com.ibuonline.b2b.entity;

import java.io.Serializable;

import com.dimeng.common.util.StringUtil;

public class CmsProductRecommend implements Serializable {

	private static final long serialVersionUID = -7323880573400076764L;

	//fields
	private java.lang.Integer catId;
	private java.lang.Long prodId;
	private java.lang.String name;
	private java.lang.String mainPicture;
	private java.lang.Integer displayOrder;

	//default constructor
	public CmsProductRecommend() {
	}

	//constructor with arguments
	public CmsProductRecommend(java.lang.Integer catId, java.lang.Long prodId) {
		this.catId = catId;
		this.prodId = prodId;
	}

	//getter
	public java.lang.Integer getCatId() {
		return catId;
	}
	public java.lang.Long getProdId() {
		return prodId;
	}
	public java.lang.String getName() {
		return name;
	}
	public java.lang.String getMainPicture() {
		return mainPicture;
	}
	public java.lang.Integer getDisplayOrder() {
		return displayOrder;
	}

	//setter
	public void setCatId(java.lang.Integer catId) {
		this.catId = catId;
	}
	public void setProdId(java.lang.Long prodId) {
		this.prodId = prodId;
	}
	public void setName(java.lang.String name) {
		this.name = name;
	}
	public void setMainPicture(java.lang.String mainPicture) {
		this.mainPicture = mainPicture;
	}
	public void setDisplayOrder(java.lang.Integer displayOrder) {
		this.displayOrder = displayOrder;
	}

	//equals method
	public boolean equals(Object other) {
		if (this == other)
			return true;
		if (!(other instanceof CmsProductRecommend))
			return false;

		final CmsProductRecommend cmsProductRecommend = (CmsProductRecommend)other;
		if (!this.catId.equals(cmsProductRecommend.getCatId()) || 
			!this.prodId.equals(cmsProductRecommend.getProdId()))
			return false;

		return true;
	}

	//hashCode method
	public int hashCode() {
		StringBuffer keys = new StringBuffer();
		keys.append(catId).append(",");
		keys.append(prodId).append(",");
		if (keys.length() > 0)
			keys.deleteCharAt(keys.length() - 1);
		return keys.toString().hashCode();
	}

	//toString method
	public String toString() {
		return new StringBuilder("CmsProductRecommend[")
			.append("catId=").append(catId).append(", ")
			.append("prodId=").append(prodId).append(", ")
			.append("name=").append(name).append(", ")
			.append("mainPicture=").append(mainPicture).append(", ")
			.append("displayOrder=").append(displayOrder).append("]").toString();
	}
	
	///##################
	
	public String getLargeMainPicResPath() {
		if (mainPicture == null)
			return null;
		return com.ibuonline.b2b.common.ResourceUtil.getResPath(mainPicture,
				com.ibuonline.b2b.common.Constants.PIC_SIZE_LARGE);
	}

	public String getMiddleMainPicResPath() {
		if (mainPicture == null)
			return null;
		return com.ibuonline.b2b.common.ResourceUtil.getResPath(mainPicture,
				com.ibuonline.b2b.common.Constants.PIC_SIZE_MIDDLE);
	}

	public String getSmallMainPicResPath() {
		if (mainPicture == null)
			return null;
		return com.ibuonline.b2b.common.ResourceUtil.getResPath(mainPicture,
				com.ibuonline.b2b.common.Constants.PIC_SIZE_SMALL);
	}

	public String getWaterMainPicResPath() {
		if (mainPicture == null)
			return null;
		return com.ibuonline.b2b.common.ResourceUtil.getResPath(mainPicture,
				com.ibuonline.b2b.common.Constants.PIC_SIZE_WATER);
	}

	public String getShowName() {
		return StringUtil.truncate(name, 6);
	}
}